package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.dto.ys.YsBusinessBudgetDTO;
import com.CST.dto.ys.YsBusinessBudgetDataDTO;
import com.CST.dto.ys.YsBudgetUpDataDTO;
import com.CST.entity.ys.YsBusinessBudgetData;
import com.CST.service.ys.YsBusinessBudgetDataService;
import com.CST.vo.ys.YsBudgetDataVO;
import com.CST.vo.ys.YsBusinessBudgetDataVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author qtx
 * @since 2023-05-22
 */
@Api(tags = "业务预算编制数据")
@RestController
@RequestMapping("/ysBusinessBudgetData")
public class YsBusinessBudgetDataController {

    private final YsBusinessBudgetDataService service;

    public YsBusinessBudgetDataController(YsBusinessBudgetDataService service) {
        this.service = service;
    }

    @ApiOperation("分页查询")
    @PostMapping("/listYsBusinessBudgetDataPage")
    public ResultObject<PageInfo<YsBusinessBudgetDataVO>> getBusinessDataList(@RequestBody YsBusinessBudgetDataDTO dto){
        return ResultObject.success(service.getBusinessDataList(dto));
    }

    @ApiOperation("编辑")
    @PostMapping("/updateYsBusinessBudgetData")
    public ResultObject<Boolean> updateYsBusinessBudgetData(@RequestBody YsBudgetUpDataDTO dataDTO) {
        return ResultObject.success(service.updateYsBusinessBudgetData(dataDTO));
    }

    @ApiOperation("导入")
    @PostMapping("/importExcelYsBusinessBudgetData/{year}")
    public ResultObject<Boolean> importExcelYsBusinessBudgetData(MultipartFile file,@PathVariable Integer year) {
        return ResultObject.success(service.importExcelYsBusinessBudgetData(file,year));
    }

    @ApiOperation("导出")
    @PostMapping("/exportExcelYsBusinessBudgetData")
    public void exportExcelYsBusinessBudgetData(HttpServletResponse response, @RequestParam Integer year) {
        service.exportExcelYsBusinessBudgetData(response, year);
    }

    @ApiOperation("导出模板")
    @PostMapping("/exportExcelYsBusinessBudgetDataDemo")
    public void exportExcelYsBusinessBudgetDataDemo(HttpServletResponse response) {
        service.exportExcelYsBusinessBudgetDataDemo(response);
    }
}
